export HF_HOME=/data/bigdata/hub
export LMUData=./eval_results
export HF_ENDPOINT=https://hf-mirror.com

# MME
# eval_datasets='MME MMVet MMMU_DEV_VAL'
# eval_datasets='MMMU_DEV_VAL MMBench_DEV_CN MME'
# MMMU_DEV_VAL
# eval_datasets='MMBench_DEV_CN MMStar MMBench_TEST_EN MMBench_TEST_CN MME MMBench_TEST_EN_V11'
# eval_datasets='MMBench_DEV_CN MMStar ChartQA_TEST Q-Bench1_VAL MMMU_VAL POPE HallusionBench RealWorldQA MMBench_TEST_EN_V11 MMBench_TEST_CN_V11 MMBench_TEST_EN MMBench_TEST_CN MME'
# eval_datasets='MMBench_DEV_CN MMStar MMMU_VAL MMBench_TEST_EN_V11 MMBench_TEST_CN_V11 MMBench_TEST_EN MMBench_TEST_CN HallusionBench RealWorldQA MME'
# eval_datasets='MMStar MMBenchDEV_CN MMMU_VAL MME MMBench_TEST_EN MMBench_TEST_CN'
# eval_datasets='MMBench_TEST_EN MMBench_TEST_CN'
eval_datasets='MMBench_TEST_EN_V11 MMBench_TEST_CN_V11'
# eval_datasets='MME'

if [ -z "$1" ]; then
    echo "Error: Please provide model name as the first argument"
    exit 1
fi

if command -v nvidia-smi &>/dev/null; then
    num_gpus=$(nvidia-smi -L 2>/dev/null | wc -l)
else
    num_gpus=0
fi

if [ "$num_gpus" -gt 0 ]; then
    echo "Using $num_gpus GPU(s)"
    num_gpus=8
    cmd="torchrun --nproc-per-node=$num_gpus --master-port=5889"
else
    echo "Using CPU mode"
    cmd="python"
fi

$cmd tests/eval_vlm.py \
    --data $eval_datasets \
    --model $1 \
    --verbose
